<template>
    <div class="newsinfo">
        <h3 class="title">{{newsinfolist.title}}</h3>
        <p class="sub_title">
            <span>发表时间：{{newsinfolist.add_time | dateFormat}}</span>
            <span>浏览：{{newsinfolist.click}}次</span>
        </p>
        <div class="newsinfo_content" v-html="newsinfolist.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>
<script>
import { Toast } from 'mint-ui'
import comment from '../subcomponents/comments.vue'
export default {
    data() {
        return {
            id:this.$route.params.id,
            newsinfolist:{}
        }
    },
    created() {
        this.getnewsinfo();
    },
    methods: {
        getnewsinfo(){
            this.$http.get("api/getnew/"+this.id).then(res=>{
                if(res.body.status === 0){
                    console.log(res.body)
                   this.newsinfolist = res.body.message[0]
                }else{
                    Toast("加载失败...")
                }
            })
        }
    },
    components:{
        'comment-box':comment
    }
}
</script>
<style lang="scss" scoped>
    .newsinfo{
        padding: 0 5px;
        .title{
            font-size: 14px;
            color: red;
            margin: 10px 0;
            text-align: center;
        }
        .sub_title{
            font-size: 12px;
            color: #226aff;
            display: flex;
            justify-content: space-between;
            border-bottom: 1px solid #999;
            padding-bottom: 5px;
        }
        img{
            width: 100%;
        }
    }
</style>
